﻿@using System.Globalization
@using Nop.Core.Domain.Customers
@using Nop.Web.Framework.UI;
@using Nop.Core;
@using Nop.Core.Domain
@using Nop.Core.Domain.Common;
@using Nop.Core.Domain.Localization
@using Nop.Services.Common
@using Nop.Services.Customers
@using Nop.Services.Security;
@{
    var kendoVersion = "2014.1.318";
    var supportRtl = EngineContext.Current.Resolve<IWorkContext>().WorkingLanguage.Rtl &&
        !EngineContext.Current.Resolve<LocalizationSettings>().IgnoreRtlPropertyForAdminArea;

    //CSS resources
    if (supportRtl)
    {
        Html.AppendCssFileParts("~/Administration/Content/styles.rtl.css");
        Html.AppendCssFileParts("~/Administration/Content/adminLTE/AdminLTE-2.3.0.rtl.css");
        Html.AppendCssFileParts("~/Administration/Content/bootstrap/css/bootstrap.rtl.css");
    }
    else
    {
        Html.AppendCssFileParts("~/Administration/Content/styles.css");
        Html.AppendCssFileParts("~/Administration/Content/adminLTE/AdminLTE-2.3.0.min.css");
        Html.AppendCssFileParts("~/Administration/Content/bootstrap/css/bootstrap.min.css");
    }

    Html.AppendCssFileParts(string.Format("~/Administration/Content/kendo/{0}/kendo.rtl.min.css", kendoVersion));
    Html.AppendCssFileParts(string.Format("~/Administration/Content/kendo/{0}/kendo.default.min.css", kendoVersion));
    Html.AppendCssFileParts(string.Format("~/Administration/Content/kendo/{0}/kendo.common.min.css", kendoVersion));
    Html.AppendCssFileParts("~/Administration/Content/jquery-ui-themes/smoothness/jquery-ui-1.10.3.custom.min.css");
    Html.AppendCssFileParts("~/Administration/Content/fontAwesome/css/font-awesome-4.6.3.min.css");
    Html.AppendCssFileParts("~/Administration/Content/typeahead/typeahead.css");
    Html.AppendCssFileParts("~/Administration/Content/bootstrap-touchspin/jquery.bootstrap-touchspin.min.css");
    <!-- AdminLTE Skins (choose a skin from the css/skins) -->
    Html.AppendCssFileParts("~/Administration/Content/adminLTE/skins/_all-skins.min.css");

    //scripts
    Html.AppendScriptParts(string.Format("~/Administration/Scripts/kendo/{0}/kendo.web.min.js", kendoVersion));
    Html.AppendScriptParts("~/Administration/Scripts/admin.search.js");
    Html.AppendScriptParts("~/Administration/scripts/admin.navigation.js");
    Html.AppendScriptParts("~/Administration/Scripts/admin.common.js");
    Html.AppendScriptParts("~/Administration/Scripts/typeahead/typeahead.bundle.min.js");
    Html.AppendScriptParts("~/Administration/Scripts/jquery-migrate-1.2.1.min.js");
    Html.AppendScriptParts("~/Administration/Scripts/jquery-ui-1.10.3.custom.min.js");
    Html.AppendScriptParts("~/Administration/Scripts/jquery.validate.unobtrusive.min.js");
    Html.AppendScriptParts("~/Administration/Scripts/jquery.validate.min.js");
    Html.AppendScriptParts("~/Administration/Scripts/adminLTE/app.min.js");
    Html.AppendScriptParts("~/Administration/Scripts/bootstrap/bootstrap.min.js");
    Html.AppendScriptParts("~/Administration/Scripts/bootstrap-touchspin/jquery.bootstrap-touchspin.min.js");
    Html.AppendScriptParts("~/Administration/Scripts/jquery-1.10.2.min.js");

    //page title
    string adminPageTitle = !String.IsNullOrWhiteSpace(ViewBag.Title) ? ViewBag.Title + " / " : "";
    adminPageTitle += T("Admin.PageTitle").Text;

    //has "Manage Maintenance" permission?
    var canManageMaintenance = EngineContext.Current.Resolve<IPermissionService>()
        .Authorize(StandardPermissionProvider.ManageMaintenance);

    //X-UA-Compatible tag
    var commonSettings = EngineContext.Current.Resolve<CommonSettings>();
    if (commonSettings.RenderXuaCompatible)
    {
        Html.AppendHeadCustomParts(string.Format("<meta http-equiv=\"X-UA-Compatible\" content=\"{0}\"/>", commonSettings.XuaCompatibleValue));
    }

    //sidebar
    const string hideSidebarAttributeName = "HideSidebar";
    var hideSidebar = EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.GetAttribute<bool>(hideSidebarAttributeName);

    //avatar
    var currentCustomer = EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer;

    //info: we specify "Admin" area for actions and widgets here for cases when we use this layout in a plugin that is running in a different area than "admin"
}

<!DOCTYPE html>
<html@(supportRtl ? Html.Raw(" dir=\"rtl\"") : null)>
    <head>
        <title>@adminPageTitle</title>
        <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
        <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
        @Html.NopHeadCustom()
        @Html.NopCssFiles(this.Url, ResourceLocation.Head, false)
        @Html.NopScripts(this.Url, ResourceLocation.Head, false)
    </head>
    <body class="hold-transition skin-blue sidebar-mini @if (hideSidebar)
                                                    {<text>sidebar-collapse</text>}">
        <div class="throbber">
            <div class="curtain">
            </div>
            <div class="curtain-content">
                <div>
                    <h1 class="throbber-header">@T("Common.Wait...")</h1>
                    <p>
                        <img src="@Url.Content("~/administration/content/images/throbber-synchronizing.gif")" alt="" />
                    </p>
                </div>
            </div>
        </div>
        <div id="ajaxBusy">
            <span>&nbsp;</span>
        </div>
        <div class="wrapper">
            @if (IsSectionDefined("header"))
            {
                @RenderSection("header")
            }
            else
            {
                @Html.Widget("admin_header_before", area: "Admin")
                <div class="main-header">
                    <a href="@Url.Content("~/admin")" class="logo">
                        <!-- mini logo for sidebar mini 50x50 pixels -->
                        <span class="logo-mini"></span>
                        <!-- logo for regular state and mobile devices -->
                        <span class="logo-lg"></span>
                    </a>
                    <div class="navbar navbar-static-top" role="navigation">
                        <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
                            <span class="sr-only">&nbsp;</span>
                        </a>
                        @Html.Widget("admin_header_toggle_after", area: "Admin")
                        <div class="navbar-custom-menu">
                            @Html.Widget("admin_header_navbar_before", area: "Admin")
                            <ul class="nav navbar-nav">
                                <li>
                                    @Html.Action("LanguageSelector", "Common", new { area = "Admin" })
                                </li>
                                @if (currentCustomer.IsRegistered())
                                {
                                    <li class="account-info">
                                        @currentCustomer.GetFullName()
                                    </li>
                                    <li>
                                        <a href="@Url.Action("Logout", "Customer", new {area = ""}, null)">
                                            @T("Admin.Header.Logout")
                                        </a>
                                    </li>
                                }
                                <li>
                                    @Html.Widget("admin_header_middle", area: "Admin")
                                </li>
                                <li>
                                    <a href="@Url.Action("Index", "Home", new {area = ""})">
                                        @T("Admin.Header.PublicStore")
                                    </a>
                                </li>
                                @if (canManageMaintenance)
                                {
                                    <li class="dropdown">
                                        <a href="#" data-toggle="dropdown"><i class="fa fa-gears"></i></a>
                                        <ul class="maintenance-menu dropdown-menu bg-light-blue" role="menu">
                                            <li>
                                                @using (Html.BeginForm("ClearCache", "Common", new { area = "Admin" }))
                                                {
                                                    @Html.AntiForgeryToken()
                                                    @Html.Hidden("returnurl", HttpContext.Current.Request.RawUrl)
                                                    <button type="submit" class="bg-light-blue">
                                                        <span>@T("Admin.Header.ClearCache")</span>
                                                    </button>
                                                }
                                            </li>
                                            <li>
                                                @using (Html.BeginForm("RestartApplication", "Common", new { area = "Admin" }))
                                                {
                                                    @Html.AntiForgeryToken()
                                                    @Html.Hidden("returnurl", HttpContext.Current.Request.RawUrl)
                                                    <button id="restart-application" type="submit" class="bg-light-blue">
                                                        <span>@T("Admin.Header.RestartApplication")</span>
                                                    </button>
                                                    <script type="text/javascript">
                                                        $(document).ready(function () {
                                                            $("#restart-application").click(function (e) {
                                                                showThrobber('@Html.Raw(HttpUtility.JavaScriptStringEncode(T("Admin.Header.RestartApplication.Progress").Text))');
                                                            });
                                                        });
                                                    </script>
                                                }
                                            </li>
                                        </ul>
                                    </li>
                                }
                            </ul>
                            @Html.Widget("admin_header_navbar_after", area: "Admin")
                        </div>
                    </div>
                </div>
                @Html.Widget("admin_header_after", area: "Admin")
            }
            @if (IsSectionDefined("headermenu"))
            {
                @RenderSection("headermenu")
            }
            else
            {
                <div class="main-sidebar">
                    <div class="sidebar">
                        @Html.Widget("admin_searchbox_before", area: "Admin")
                        <div class="sidebar-form">
                            <div id="search-box">
                                <input type="text" class="form-control admin-search-box typeahead" placeholder="@T("Admin.Menu.Search")">
                            </div>
                        </div>
                        <script>
                            $(document).ready(function () {
                                Admin.Search.init();
                            });
                        </script>
                        @Html.Widget("admin_menu_before", area: "Admin")
                        @Html.Partial("Menu")
                    </div>
                </div>
            }
            <div class="content-wrapper">
                @Html.Partial("Notifications")
                <div>
                    @RenderBody()
                </div>
            </div>
            <div class="main-footer clearfix">
                @if (!EngineContext.Current.Resolve<StoreInformationSettings>().HidePoweredByNopCommerce)
                {
                    @*Would you like to remove the "Powered by nopCommerce" link in the bottom of the footer?
                        Please find more info at http://www.nopcommerce.com/copyrightremoval.aspx*@
                    <div class="pull-left">
                        Powered by <a href="http://www.nopcommerce.com/?utm_source=admin-panel&utm_medium=footer&utm_campaign=admin-panel" target="_blank">nopCommerce</a>
                    </div>
                }
                <div class="pull-right hidden-xs">
                    <b>nopCommerce version @NopVersion.CurrentVersion</b>
                </div>
                <div class="text-center">
                    @{
                        var dateTimeHelper = EngineContext.Current.Resolve<Nop.Services.Helpers.IDateTimeHelper>();
                        var workContext = EngineContext.Current.Resolve<IWorkContext>();
                        var currentCulture = new CultureInfo(workContext.WorkingLanguage.LanguageCulture);
                    }
                    @dateTimeHelper.ConvertToUserTime(DateTime.Now).ToString("f", currentCulture)
                </div>
            </div>
        </div>
        <script>
            var AdminLTEOptions = {
                boxWidgetOptions: {
                    boxWidgetIcons: {
                        collapse: 'fa-minus',
                        open: 'fa-plus'
                    }
                }
            };
        </script>
        @Html.NopCssFiles(this.Url, ResourceLocation.Foot)
        @Html.NopScripts(this.Url, ResourceLocation.Foot)
        <a id="backTop" class="btn btn-back-top bg-teal"></a>
        <script>
            $(document).ready(function () {
                $('#backTop').backTop();

                $('a.sidebar-toggle').on('click', function () {
                    var collapsed = $('body').hasClass('sidebar-collapse');
                    saveUserPreferences('@(Url.Action("SavePreference", "Preferences"))', '@hideSidebarAttributeName', collapsed);
                });
            });
        </script>
    </body>
</html>